package com.mjlf.hometeach.teacher.controller;

import com.mjlf.hometeach.common.entity.StatusCode;
import com.mjlf.hometeach.common.utils.ResponseUtil;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @auther a123
 * @create 2018-04-25 23:01
 * @desc 模板Contrller类
 */

@RestController
@RequestMapping("/home-teach")
public class TemplateController {

    Logger logger = LoggerFactory.getLogger(TemplateController.class);

    @RequestMapping(value = {"GET", "/template"})
    public void getActivity(HttpServletRequest request, HttpServletResponse response) {
        String code = "system_error";
        JSONObject data = new JSONObject();
        try {
            data.put("message", "hello parent");
        } catch (Exception e) {
            if (!code.equals(StatusCode.OK)) {
                code = StatusCode.SYSTEM_ERROR;
            }
            logger.error(e.getMessage(), e);
        } finally {
            ResponseUtil.responseResult(code, data, response);
        }
    }
}
